package org.iiitb.assignment.wizards;

import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

public class WScreenTwo extends WizardPage {
	private Text from,to,via1,via2,via3;
	private Composite container;

	public WScreenTwo() {
		super("Second Page");
		setTitle("Travel Details");
		setDescription("Enter the travel details here.");
		//setControl(text1);
	}

	@Override
	public void createControl(Composite parent) {
		container = new Composite(parent, SWT.NULL);
		container.setLayout(new GridLayout(2,false));
		
		Label l1 = new Label(container, SWT.NULL);
		l1.setText("FROM : ");

		from = new Text(container, SWT.BORDER | SWT.SINGLE);
		from.setText("");
		from.addKeyListener(new KeyListener() {

			@Override
			public void keyPressed(KeyEvent e) {
				// TODO Auto-generated method stub

			}

			@Override
			public void keyReleased(KeyEvent e) {
				if (!from.getText().isEmpty()&&!to.getText().isEmpty()) {
					setPageComplete(true);
				}else{
					setPageComplete(false);
				}
			}

		});
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
		from.setLayoutData(gd);

		Label l2 = new Label(container, SWT.NULL);
		l2.setText("TO : ");

		to = new Text(container, SWT.BORDER | SWT.SINGLE);
		to.setText("");
		to.addKeyListener(new KeyListener() {

			@Override
			public void keyPressed(KeyEvent e) {
				// TODO Auto-generated method stub

			}

			@Override
			public void keyReleased(KeyEvent e) {
				if (!from.getText().isEmpty()&&!to.getText().isEmpty()) {
					setPageComplete(true);
				}else{
					setPageComplete(false);
				}
			}

		});
		
		to.setLayoutData(gd);

		Label l3 = new Label(container, SWT.NULL);
		l3.setText("via : ");

		via1 = new Text(container, SWT.BORDER | SWT.SINGLE);
		via1.setText("");
		via1.setLayoutData(gd);

		Label l4 = new Label(container, SWT.NULL);
		l4.setText("via : ");

		via2 = new Text(container, SWT.BORDER | SWT.SINGLE);
		via2.setText("");
		via2.setLayoutData(gd);

		Label l5 = new Label(container, SWT.NULL);
		l5.setText("via : ");

		via3 = new Text(container, SWT.BORDER | SWT.SINGLE);
		via3.setText("");
		via3.setLayoutData(gd);

		// Required to avoid an error in the system
		setControl(container);
		setPageComplete(false);
	}

	public String getFrom() {
		return from.getText();
	}

	public String getTo() {
		return to.getText();
	}

	public String getVia1() {
		return via1.getText();
	}

	public String getVia2() {
		return via2.getText();
	}

	public String getVia3() {
		return via3.getText();
	}
} 